<template>
  <div class="container">
    <div ref="screen" class="screen_container">
      <!-- 数据大屏顶部 -->
      <Top />
      <div class="bottom">
        <div class="left">
          <Tourise class="tourise" />
          <Sex class="sex" />
          <Age class="age" />
        </div>
        <div class="center">
          <GrandMap class="grandMap" />
          <Line class="line" />
        </div>
        <div class="right">
          <Rank class="rank" />
          <Year class="year" />
          <Couter class="couter" />
        </div>
      </div>
    </div>
  </div>
</template>
<script setup lang="ts">
import { ref, onMounted } from "vue";
// 引入顶部子组件
import Top from "./components/top/index.vue";
// 引入左侧三个子组件
import Tourise from "./components/tourist/index.vue";
import Sex from "./components/sex/index.vue";
import Age from "./components/age/index.vue";
import GrandMap from "./components/map/index.vue";
import Line from "./components/line/index.vue";
import Couter from "./components/couter/index.vue";
import Year from "./components/year/index.vue";
import Rank from "./components/rank/index.vue";
// 获取数据大屏展示内容盒子的DOM元素
let screen = ref();
onMounted(() => {
  screen.value.style.transform = `scale(${getScale()}) translate(-50%,-50%)`;
});
// 定义大屏幕缩放比例
function getScale(w = 1920, h = 1080) {
  const ww = window.innerWidth / w;
  const wh = window.innerHeight / h;
  return ww < wh ? ww : wh;
}
// 监听视口的变化
window.onresize = () => {
  screen.value.style.transform = `scale(${getScale()}) translate(-50%,-50%)`;
};
</script>
<style scoped lang="scss">
.container {
  width: 100vw;
  height: 100vh;
  background: url("../../assets/images/screen/bg.png") no-repeat;
  background-size: cover;

  .screen_container {
    position: fixed;
    width: 1920px;
    height: 1080px;
    left: 50%;
    top: 50%;
    transform-origin: left top;

    .top {
      width: 100%;
      height: 40px;
    }

    .bottom {
      display: flex;

      .left {
        flex: 1;
        height: 1040px;
        display: flex;
        flex-direction: column;

        .tourise,
        .sex,
        .age {
          flex: 1;
          margin: 10px 0;
        }

        .tourise {
          flex: 1.5;
        }
      }

      .right {
        flex: 1;
        height: 1040px;
        display: flex;
        flex-direction: column;

        .rank,
        .year,
        .couter {
          flex: 1;
          margin: 10px 0;
        }

        .rank {
          flex: 1.5;
        }
      }

      .center {
        flex: 2;
        display: flex;
        flex-direction: column;
        margin-top: 34px;
        height: calc(1080px - 86px);

        .grandMap {
          flex: 3;
        }

        .line {
          flex: 1;
        }
      }
    }
  }
}
</style>
